#pragma once
#include <DShow.h>
#include <qedit.h>

// Constants
#define WM_CAPTURE_BITMAP   WM_APP + 1

typedef struct _callbackinfo 
{
	double dblSampleTime;
	long lBufferSize;
	BYTE *pBuffer;
	BITMAPINFOHEADER bih;

} CALLBACKINFO;


class CSampleGrabberCB : public ISampleGrabberCB 
{
public:
	CSampleGrabberCB(void);
	~CSampleGrabberCB(void);

protected:
	// these will get set by the main thread below. We need to
	// know this in order to write out the bmp
	long m_lWidth;
	long m_lHeight;
	HWND m_hOwner;
	BOOL m_bOneShot;
	TCHAR m_szCapDir[MAX_PATH]; // the directory we want to capture to
	TCHAR m_szSnappedName[MAX_PATH];

public:
	void SetOwner(HWND hWnd) {m_hOwner = hWnd;}
	void SetFilePath(const char* pPath);

public:
	// fake out any COM ref counting
	//
	STDMETHODIMP_(ULONG) AddRef() { return 1; }
	STDMETHODIMP_(ULONG) Release() { return 1; }

	// fake out any COM QI'ing
	//
	STDMETHODIMP QueryInterface(REFIID riid, void ** ppv);

	STDMETHODIMP SampleCB( double SampleTime, IMediaSample * pSample ){return 0;}
	STDMETHODIMP BufferCB( double dblSampleTime, BYTE * pBuffer, long lBufferSize );

	BOOL SaveBitmap( double dblSampleTime, BYTE * pBuffer, long lBufferSize );
	void SetOneShot(BOOL bOneShot) {m_bOneShot = bOneShot;}
	void SetWidth(long lWidth) {m_lWidth = lWidth;}
	void SetHeight(long lHeight) {m_lHeight = lHeight;}
};
